class FnFalACOGFireOld extends MachinegunFire;

// Calculate modifications to spread
simulated function float GetSpread()
{
	local float NewSpread;
	local float AccuracyMod;

	AccuracyMod = 1.0;

	// Spread bonus for firing aiming
	if( KFWeap.bAimingRifle )
	{
		AccuracyMod *= 0.5;
	}

	// Small spread bonus for firing crouched
	if( Instigator != none && Instigator.bIsCrouched )
	{
		AccuracyMod *= 0.85;
	}

	// Small spread bonus for firing in semi auto mode
	if( bWaitForRelease )
	{
		AccuracyMod *= 0.85;
	}


	NumShotsInBurst += 1;

	if ( Level.TimeSeconds - LastFireTime > 0.5 )
	{
		NewSpread = Default.Spread;
		NumShotsInBurst=0;
	}
	else
	{
		// Decrease accuracy up to MaxSpread by the number of recent shots up to a max of six
		NewSpread = FMin(Default.Spread + (NumShotsInBurst * (MaxSpread/6.0)),MaxSpread);
	}

	NewSpread *= AccuracyMod;

	return NewSpread;
}

simulated function HandleRecoil(float Rec)
{
	local rotator NewRecoilRotation;
	local KFPlayerController KFPC;
	local KFPawn KFPwn;

    if( Instigator != none )
    {
		KFPC = KFPlayerController(Instigator.Controller);
		KFPwn = KFPawn(Instigator);
	}

    if( KFPC == none || KFPwn == none )
    	return;

	if( !KFPC.bFreeCamera )
	{
    	if( Weapon.GetFireMode(0).bWaitForRelease == false )
    	{
          	NewRecoilRotation.Pitch = RandRange( maxVerticalRecoilAngle * 0.5, maxVerticalRecoilAngle );
         	NewRecoilRotation.Yaw = RandRange( maxHorizontalRecoilAngle * 0.5, maxHorizontalRecoilAngle );

    	    NewRecoilRotation.Pitch += (VSize(Weapon.Owner.Velocity)* 3);
    	    NewRecoilRotation.Yaw += (VSize(Weapon.Owner.Velocity)* 3);
    	    NewRecoilRotation.Pitch += (Instigator.HealthMax / Instigator.Health * 5);
    	    NewRecoilRotation.Yaw += (Instigator.HealthMax / Instigator.Health * 5);
    	    NewRecoilRotation *= Rec;

 		    KFPC.SetRecoil(NewRecoilRotation,RecoilRate / (default.FireRate/FireRate));
    	}
    	else
    	{
    	    NewRecoilRotation.Pitch = RandRange( maxVerticalRecoilAngle * 0.1, maxVerticalRecoilAngle * 0.2 );
         	NewRecoilRotation.Yaw = RandRange( maxHorizontalRecoilAngle * 0.1, maxHorizontalRecoilAngle * 0.2 );



            KFPC.SetRecoil(NewRecoilRotation,RecoilRate);
    	}
 	}

}

defaultproperties
{
	 Penetration=0.55
	 bWaitForRelease=true
     RecoilRate=0.080000
     maxVerticalRecoilAngle=150
     maxHorizontalRecoilAngle=115
     ShellEjectClass=Class'KFMod.KFShellEjectFAL'
     ShellEjectBoneName="Shell_eject"
     bRandomPitchFireSound=False
     FireSoundRef="KF_FNFALSnd.FNFAL_Fire_Single_M"
     StereoFireSoundRef="KF_FNFALSnd.FNFAL_Fire_Single_S"
     NoAmmoSoundRef="KF_SCARSnd.SCAR_DryFire"
     DamageType=Class'DamTypeFnFal'
     DamageMin=100
     DamageMax=100
     Momentum=8500.000000
     FireRate=0.142857
     AmmoClass=Class'FnFalACOGAmmo'
     ShakeRotMag=(X=80.000000,Y=80.000000,Z=450.000000)
     ShakeRotRate=(X=7500.000000,Y=7500.000000,Z=7500.000000)
     ShakeRotTime=0.650000
     ShakeOffsetMag=(X=6.000000,Y=3.000000,Z=8.500000)
     ShakeOffsetRate=(X=1000.000000,Y=1000.000000,Z=1000.000000)
     ShakeOffsetTime=1.150000
     BotRefireRate=0.990000
     FlashEmitterClass=Class'ROEffects.MuzzleFlash1stSTG'
     aimerror=42.000000
     Spread=0.008500
     SpreadStyle=SS_Random
}
